5. Transformation rules extraction

(c) 2019, Dr. Ramil Nugmanov; Dr. Timur Madzhidov; Ravil Mukhametgaleev

Installation instructions of CGRtools package information and tutorial's files see on https://github.com/cimm-kzn/CGRtools

NOTE: Tutorial should be performed sequentially from the start. Random cell running will lead to unexpected results.


In [ ]:
import pkg_resources
if pkg_resources.get_distribution('CGRtools').version.split('.')[:2] != ['3', '1']:
    print('WARNING. Tutorial was tested on 3.1 version of CGRtools')
else:
    print('Welcome!')

In [ ]:
# load data for tutorial
from pickle import load
from traceback import format_exc

with open('molecules.dat', 'rb') as f:
    molecules = load(f) # list of MoleculeContainer objects
with open('reactions.dat', 'rb') as f:
    reactions = load(f) # list of ReactionContainer objects

m3 = molecules[2]
m7 = m3.copy()
m7.standardize()
r1 = reactions[0] # reaction
m8 = m7.substructure([4, 5, 6, 7, 8, 9], as_view=False)
cgr1 = m7 ^ m8 
cgr1.reset_query_marks() 

from CGRtools.containers import *

CGRtools can be used to generate molecules and reactions based on a given transformation rule.

How to extract transformation rule


In [ ]:
cgr1.center_atoms # list of atom numbers of reaction center. If several centers exist they will also be added to this list.

In [ ]:
cgr1.center_bonds # list of dynamic bonds as tuples of adjacent atom numbers

In [ ]:
cgr1.centers_list # list of lists of atom numbers belonging to each reaction center. 
                  # Distant reaction centers will be split into separate lists

In [ ]:
rc1 = cgr1.substructure([13, 7]) # get reaction center from CGR
format(rc1, 'hn')               # Notice that query marks are set.

rc1 is phenol reduction, phenol is transformed into unsubstituted benzene:

  • [C;a3;]-aromatic carbon with 3 neighbors
  • [O;s1;]-oxygen with 1 neighbor
  • [C;a2;]-carbon with 2 neighbors
  • [O;s0;]-oxygen without neighbors (water). It probably appears since initial reaction was unbalanced.

In [ ]:
rule = QueryCGRContainer(rc1) # transform reaction into query to take query

In [ ]:
print(rule) # all query marks are on their place. Without them generation will be too unrestrictive. 
            # If needed CGRtools could be used to include atomic environment, etc...